#include <iostream>
using namespace std;
/*
    【题目210】声明一个Shape基类，在此基础上派生出Rectangle类和Circle类，二者都有
    GetArea()函数计算对象的面积。使用Rectangle类创建一个派生类Square。
*/

class Shape
{
private:
    double s; // 面积

public:
    Shape(double s) : s(s)
    {
    }
    double GetArea()
    {
        return s;
    }
};

class Rectangle : public Shape
{
public:
    Rectangle(double w, double h) : Shape(w * h)
    {
        this->w = w;
        this->h = h;
    }

private:
    double w; // 宽
    double h; // 高
};

class Square : public Rectangle
{
public:
    Square(double w) : Rectangle(w, w)
    {
    }
};

class Circle : public Shape
{
public:
    Circle(double r) : Shape(r * r * 3.14)
    {
        this->r = r;
    }

private:
    double r; // 半径
};

int main()
{
    Square s(10);
    cout << s.GetArea() << endl;
    Circle c(10);
    cout << c.GetArea() << endl;
    Rectangle r(10, 10);
    cout << r.GetArea() << endl;

    return 0;
}